<template>
  <div>
  <h1>{{ msg }}</h1>
  <p>当前登录用户是：{{ currentUser }}，所属组织机构：{{currentOrg}} <span>&nbsp;&nbsp;&nbsp;</span>  <a href="#" v-on:click='logout'>注销</a></p>
  </div>
</template>

<script>
import global from '../global'
export default {
  name: 'HomePage',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      currentUser: '',
      currentOrg: ''
    }
  },
  created: function () {
    this.$axios.post('web_api/getLoginedUserInfo', {
      session_id: global.getSession_id(),
      session_vc: global.getSession_vc()
    }).then((res) => {
      console.log(res)
      this.currentUser = res.data.data.userTitle
      this.currentOrg = res.data.data.userOrg
    }).catch((res) => {
      console.log(res)
    })
  },
  methods: {
    logout: function () {
      this.$axios.post('web_api/logout', {
        synch_req: true,
        session_id: global.getSession_id(),
        session_vc: global.getSession_vc()
      }).then((res) => {
        console.log(res)
        global.logout()
      }).catch((res) => {
        console.log(res)
      })
    }
  }
}
</script>

<style scoped>

</style>
